package com.isorf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.isorf.mapper.ColorMapper;
import com.isorf.pojo.Color;
import com.isorf.service.ColorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ColorServiceImpl implements ColorService {
    @Autowired
    private ColorMapper colorMapper;

    @Override
    public Boolean addColor(Color color) {
        int result = colorMapper.addColor(color);
        return result > 0;
    }

    @Override
    public Boolean deleteColor(int colorId) {
        int result = colorMapper.deleteColor(colorId);
        return result > 0;
    }

    @Override
    public Boolean updateColor(Color color) {
        int result = colorMapper.updateColor(color);
        return result > 0;
    }

    @Override
    public Color getColorById(int colorId) {
        return colorMapper.getColorById(colorId);
    }

    @Override
    public PageInfo<Color> pageList(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Color> list = colorMapper.getAllColors();
        return new PageInfo<>(list);
    }

    @Override
    public List<Color> getAllColors() {
        return colorMapper.getAllColors();
    }
} 